/**
 * 判断dom是否进入可视区
 */
export const isElementInViewport = (el) => {
  const rect = el.getBoundingClientRect()
  return (
    rect.top >= 0 &&
    rect.left >= 0 &&
    rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
    &&
    rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  )
}

/**
 * 判断是否滚动到浏览器底部
 */
export const isScrollToBottom = () => {
  const scrollY = window.scrollY
  //获取页面的可视高度
  const windowHeight = window.innerHeight
  //滚动高度
  const pageHeight = document.documentElement.scrollHeight
  return (scrollY+windowHeight) >= pageHeight
}
